feat(__future__): Identify MV options by key in experimental update-flags endpoint#8000
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Docker builds report
|
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
|
Visual Regression19 screenshots compared. See report for details. |
31389bf to
0c2b855
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/multivariate-update-flag-endpoints #8000 +/- ##
========================================================================
Coverage 98.64% 98.64%
========================================================================
Files 1498 1498
Lines 59410 59494 +84
========================================================================
+ Hits 58604 58688 +84
Misses 806 806 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
0c2b855 to
541931c
Compare
| def _validate_overrides_reweight_environment_options( | ||
| feature: Feature, | ||
| environment_multivariate_values: Sequence[EnvironmentMultivariateValuePayload], | ||
| override_multivariate_value_lists: Sequence[ | ||
| Sequence[SegmentOverrideMultivariateValuePayload] | ||
| ], | ||
| ) -> None: | ||
| option_id_by_key: dict[str, int] = { | ||
| key: option_id | ||
| for key, option_id in feature.multivariate_options.filter( | ||
| key__isnull=False | ||
| ).values_list("key", "id") | ||
| if key is not None | ||
| } | ||
| allowed_keys = {mv["key"] for mv in environment_multivariate_values if "key" in mv} | ||
| allowed_option_ids = { | ||
| mv["multivariate_feature_option"] | ||
| for mv in environment_multivariate_values | ||
| if "multivariate_feature_option" in mv | ||
| } | {option_id_by_key[key] for key in allowed_keys if key in option_id_by_key} | ||
| for multivariate_values in override_multivariate_value_lists: | ||
| for mv in multivariate_values: | ||
| if "multivariate_feature_option" in mv: | ||
| allowed = mv["multivariate_feature_option"] in allowed_option_ids | ||
| else: | ||
| allowed = ( | ||
| mv["key"] in allowed_keys | ||
| or option_id_by_key.get(mv["key"]) in allowed_option_ids | ||
| ) | ||
| if not allowed: | ||
| raise serializers.ValidationError( | ||
| { | ||
| "multivariate_feature_state_values": [ | ||
| "Segment overrides can only re-weight existing variants." | ||
| ] | ||
| } | ||
| ) |
There was a problem hiding this comment.
Can you explain why we need this together with _validate_multivariate_keys_exist?
matthewelwell
left a comment
There was a problem hiding this comment.
Added a few high-level comments. I think the key question is whether we should allow the creation of new multivariate options as part of these endpoints. IMO we shouldn't...
| expected_direction = serializers.ChoiceField(choices=ExpectedDirection.choices) | ||
|
|
||
|
|
||
| class RolloutMultivariateValueSerializer( |
There was a problem hiding this comment.
Where did this name come from? I don't quite understand how Rollout and MultivariateValue are related?
| update_multivariate_values(feature_state, reweighted_values) | ||
|
|
||
|
|
||
| def _upsert_multivariate_option_by_key( |
There was a problem hiding this comment.
I'm a bit unsure why we're adding upsert functionality here? Do we need to?
Without having the full context my thoughts here are that it would complicate things unnecessarily. If we restrict the creation of multivariate values to a single place, then we can more easily implement restrictions such as not being able to create new variations when an experiment is taking place.
| assert "not found in project" in str(response.json()) | ||
|
|
||
|
|
||
| def test_update_flag_option_b__keyed_variants_in_single_request__configures_environment_and_overrides_segment( |
There was a problem hiding this comment.
Why are we still referencing option_b here - I thought we were removing the different options?
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Timeline for context
"key"attribute to identify multivariate options (feat(multivariate): add per-feature unique key to multivariate options #7698).Changes
Contributes to #7642
Similarly to how a feature can be identified in the experimental update-flag endpoints, i.e. by either its ID or name, now we allow multivariate options to be identified by either their ID or [the new] key.
This means to make it easier to use update-flag, eliminating retrieving an MV ID as an extra step to achieving the use case of updating or re-weighting multivariates.
How did you test this code?
New tests.